<?php

/**
 * @author superx
 * @package Core
 * @example
 * { loc : [ 50 , 30 ] } //SUGGESTED OPTION
 */
class Core_Validator_GeoPoint implements Core_Validator_Interface {
    public function isValid($data) {
        if (!is_array($data) || count($data) != 2) {
            return false;
        }
        $longitude = array_pop($data);
        $latitude = array_pop($data);
        // check on input from some android
        if ($latitude == '-1' && $longitude == '-1') {
            return false;
        }
        if ($latitude == '0' && $longitude == '0') {
            return false;
        }
        if (abs($latitude) <= 0.001 || abs($longitude) <= 0.001) {
            return false;
        }

        if ($latitude < -90 || $latitude >= 90) {
            return false;
        }
        if ($longitude < -180 || $longitude >= 180) {
            return false;
        }

        return true;
    }
}
